/**
 * @param {number[]} nums
 * @return {number}
 */
var missingNumber = function(nums) {
    let length = nums.length;
    if(length===0)return 0;
    let sum = (1+length)/2*length;
    return sum - nums.reduce((a,b)=>a+b);
};


console.log(missingNumber([0]));